﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EventReminder.Server
{
    class EventProcessorEnumerator : IEnumerator<IEventProcessor>
    {
        IEventProcessor _currentLink;
        IEventProcessor _startLink;

        public EventProcessorEnumerator(IEventProcessor topOfChain)
        {
            _currentLink = topOfChain;
            _startLink = topOfChain;
        }

        public IEventProcessor Current
        {
            get { return _currentLink; }
        }

        public void Dispose()
        {
            _currentLink = null;
            _startLink = null;
        }

        object System.Collections.IEnumerator.Current
        {
            get { return _currentLink; }
        }

        public bool MoveNext()
        {
            _currentLink = _currentLink.NextLink;
            return _currentLink != null;
        }

        public void Reset()
        {
            _currentLink = _startLink;
        }
    }
}
